//
//  BaseTableViewController.swift
//  NSinaWeibo
//
//  Created by LoliQueen on 16/2/16.
//  Copyright © 2016年 LoliQueen. All rights reserved.
//

import UIKit

//遵守协议 设置代理
class BaseTableViewController: UITableViewController ,VisitorLoginViewDelegate{

    //登陆标记  access_token 标示登陆成功
    var userLongin = AccountViewModel.shareAccountViewModel.userLogin
    //设置可视化视图属性，供外部使用
    var visitorLoginView: VisitorLoginView?
    
    //根据用户是否登陆，判断显示方可视图还是tabelView
    override func loadView() {
        if userLongin {
        //显示tabelView
            super.loadView()
        }else{
            visitorLoginView = VisitorLoginView()
            visitorLoginView?.loginViewDelegate = self
            view = visitorLoginView
            
            //添加导航条按钮
            navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "userWillLogin")
            navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
        }
        
    }
    
    //实现代理方法
    func userWillLogin() {
        print(__FUNCTION__)
        //modal出登陆认证界面
        let OAuht = OAuthViewControler()
        let nav = UINavigationController(rootViewController: OAuht)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func userWillRegister() {
        print(__FUNCTION__)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }

   

}
